package com.easybuilder.blog.dao;

import com.easybuilder.blog.entity.BlogReply;
import com.easybuilder.common.base.dao.BaseDao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.ExampleMapper;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface BlogReplyDao extends BaseDao<BlogReply>, ExampleMapper<BlogReply> {

    /** 根据回复类型和回复对象id，获取回复列表*/
    @Select("select * from blog_reply where type = #{type} and reply_id = #{replyId} order by create_time desc")
    List<BlogReply> selectByTypeAndReplyId(int type, Long replyId);

    /** 统计数量 */
    @Select("select count(1) from blog_reply union all select count(1) from blog_reply where create_time like '${date}%'")
    List<Integer> countReply(@Param("date") String date);
}